<?php

class User_AuthController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
    }

    public function loginAction()
    {
        // action body
		$request = $this->getRequest();
		$loginForm = new User_Form_Login();
		
		if ($this->getRequest()->isPost()) {
            if ($loginForm->isValid($request->getPost())) {
				$uname = $loginForm->getValue('username');
				$paswd = $loginForm->getValue('password');
				$flag = User_Plugin_Core::authenticate($uname, $paswd);
				if ($flag === false) {
					
				}
				$this->_redirect(str_replace($this->getRequest()->getBaseUrl(), '', $this->getRequest()->getRequestUri()));
			}
		}
		
		$this->view->loginForm = $loginForm;
    }
	
	public function logoutAction()
    {
		$this->_helper->layout()->disableLayout();
		$this->_helper->viewRenderer->setNoRender(true);
        User_Plugin_Core::logout();
		$this->_redirect('/');
    }


}



